# ppt 增加流程图

from pptx import Presentation
from pptx.enum.shapes import MSO_AUTO_SHAPE_TYPE
from pptx.util import Inches, Pt


def base_use():
    ppt = Presentation()
    slide = ppt.slides.add_slide(ppt.slide_layouts[1])
    shapes = slide.shapes
    shapes.title.text = '流程图'

    left = 1
    width = 1.5
    # 增加流程图
    t_sh = shapes.add_shape(MSO_AUTO_SHAPE_TYPE.PENTAGON, left=Inches(left), top=Inches(4), width=Inches(width), height=Inches(0.5))
    t_sh.text = f'第1步'

    for i in range(2, 5):
        left = left + width
        t_sh = shapes.add_shape(MSO_AUTO_SHAPE_TYPE.CHEVRON, left=Inches(left), top=Inches(4), width=Inches(width), height=Inches(0.5))
        p = t_sh.text_frame
        p.text = f'第{i}步'
        p.fit_text(max_size=10,bold=True,italic=True)     # 填充自适应字号，必须是设置内容之后

    ppt.save('../02.py_pptFile/03.ppt增加流程图.pptx')


if __name__ == '__main__':
    base_use()
